package com.lz.hotel_java.mapper;

import com.lz.hotel_java.entity.Customer;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface CustomerMapper {
    @Select("SELECT * FROM Customer WHERE CustomerID = #{customerID}")
    Customer selectById(Integer customerID);

    @Select("SELECT * FROM Customer")
    List<Customer> selectAll();

    @Insert("INSERT INTO Customer(Name, IDCard, Phone) VALUES(#{name}, #{idCard}, #{phone})")
    @Options(useGeneratedKeys = true, keyProperty = "customerID")
    int insert(Customer customer);

    @Update("UPDATE Customer SET Name = #{name}, IDCard = #{idCard}, Phone = #{phone} WHERE CustomerID = #{customerID}")
    int update(Customer customer);

    @Delete("DELETE FROM Customer WHERE CustomerID = #{customerID}")
    int deleteById(Integer customerID);
    @Select("SELECT * FROM Customer WHERE IDCard = #{idCard}")
    Customer findByIdCard(String idCard);
}

